package com.example.shop.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.shop.R;

import java.util.List;

/**
 * Created by Administrator on 2016/3/15.
 */
public class ItemExlvSearchFragAdapter extends  MyExLvAdapter {
    private Activity mActivity;
    private LayoutInflater mLayoutInflater;
    List<String[]> mChildDatas;
    String[] mGroupDatas;
    public ItemExlvSearchFragAdapter(Activity activity, List<String[]> childDatas,String[] groupDatas) {
        mActivity = activity;
        mGroupDatas = groupDatas;
        mChildDatas=childDatas;
        mLayoutInflater=mActivity.getLayoutInflater();
    }

    @Override
    public int getGroupCount() {
        return mGroupDatas.length;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return mChildDatas.get(groupPosition).length;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        TextView textViewGroup= (TextView) mLayoutInflater.inflate(R.layout.item_exlv_group_search_frag,parent,false);
        textViewGroup.setText(mGroupDatas[groupPosition]);
        return textViewGroup;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        TextView textViewChild= (TextView) mLayoutInflater.inflate(R.layout.item_exlv_chilid_search_frag,parent,false);
        textViewChild.setText(mChildDatas.get(groupPosition)[childPosition]);
        return textViewChild;
    }
}
